{% load static %}
<!DOCTYPE html>
<!-- saved from url=(0050)http://www.jq22.com/demo/jquery-Sharelink20151012/ -->
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>24期后宫</title>
    <link rel="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body>
<div class="login-container">
    <h1>你瞅啥</h1>
    <div class="connect">
        <p style="left: 0%;">赶紧进来小老弟</p>
    </div>
    <form action="" method="post" id="loginForm"
          novalidate="novalidate">
        <span class="login_error" style="color:red;"></span>
        <div>
            <input type="text" name="username" class="username" placeholder="用户名" autocomplete="off">
        </div>
        <div>
            <input type="password" name="password" class="password" placeholder="密码" oncontextmenu="return false"
                   onpaste="return false">

        </div>

{#        <button id="submit" type="submit">登 陆</button>#}
        <button id="submit" type="button">登 陆</button>
    </form>
    <a href="{% url 'register' %}">
        <button type="button" class="register-tis">办个会员吧？</button>
    </a>

</div>

<script src="{% static 'js/jquery.min.js' %}"></script>
{#<script src="./登陆丨Sharelink_files/jquery.min.js(1).下载"></script>#}
<script src="{% static 'js/common.js' %}"></script>

<script src="{% static 'js/supersized.3.2.7.min.js' %}"></script>
<script src="{% static 'js/supersized-init.js' %}"></script>

<script src="{% static 'js/jquery.validate.min.js' %}"></script>

<script>
    $("#submit").click(function () {

        var uname = $('.username').val();
        var pwd = $('.password').val();
        $.ajax({
            url:'{% url "login" %}',
            type:'post',
            data:{username:uname,password:pwd,csrfmiddlewaretoken:'{{ csrf_token }}'},
            success:function (res) {  //{'status':1,'home':'/home/','msg':'用户名或者秘密错误'}
                if (res.status === 1){
                    location.href=res.home

                }else {
                    $('.login_error').text(res.msg)


                }

            }

        })


    })


</script>

</body>
</html>